<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix='fmt'%>
<%@ taglib uri="/tags/trymore" prefix="tm"%>

<script type="text/javascript">
	function callback_userRemove(id) {
		if ($("#user-" + id).size() > 0) {
			$("#user-" + id).fadeOut("slow");
		}
	}
	
	function after_reset() {
		alertMsg.correct("密码重置成功...");
	}
</script>

<form id="pagerForm" method="post" action="app/system/account.do?action=pageAccountIndex">
	<input type="hidden" name="pageNum" value="${pagingBean ne null ? pagingBean.currentPage : 1}" />
	<input type="hidden" name="numPerPage" value="${pagingBean ne null ? pagingBean.pageSize : 20}" />
</form>

<!-- SearchBar -->
<div class="pageHeader">
	<form onsubmit="return navTabSearch(this);" action="app/system/account.do?action=pageAccountIndex" method="post" id="searchForm" rel="pagerForm">
		<div class="searchBar">
			<table class="searchContent">
				<tr>
					<td>
						<label>用户账号：</label>
						<input type="text" name="userNo" rel="pagerForm" value="${userNo ne null ? userNo : ''}" />
					</td>
					<td>
						<label>用户姓名：</label>
						<input type="text" name="username" rel="pagerForm" value="${username ne null ? username : ''}" />
					</td>
				</tr>
			</table>
			<div class="subBar">
				<ul>
					<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
				</ul>
			</div>
		</div>
	</form>
</div>

<!-- Body -->	
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			<li>
				<a class="add" href="app/system/account.do?action=dialogAccountPage" target="dialog" title="添加新账号" mask="true" width="554" height="308" rel="dia_sys_usradd">
					<span>添加新账号</span>
				</a>
			</li>
		</ul>
	</div>

	<table class="table" width="100%" layoutH="138">
		<thead>
			<tr>
				<th align="center">用户账号</th>
				<th align="center">用户姓名</th>
				<th align="center">用户角色</th>
				<th align="center">用户状态</th>
				<th align="center">联系电话</th>
				<th align="center">邮箱地址</th>
				<th align="center">最后登录时间</th>
				<th align="center">最后登录IP</th>
				<th align="center">激活/冻结</th>
				<th align="center">重置密码</th>
				<th align="center">账号编辑</th>
				<th align="center">账号删除</th>
			</tr>
		</thead>
		<tbody>
			<logic:present name="datagrid">
				<logic:iterate name="datagrid" property="items" id="user" indexId="idx">
					<tr id="user-${user.id}" ${idx % 2 == 1 ? 'style="background-color: #F5F5F5"' : ''}>
						<td>${user.userNo}</td>
						<td style="text-align: left">${user.username}</td>
						<td>${user.userRole ne null ? user.roleName : '/'}</td>
						<td style="background-color: ${user.userStatus eq 1 ? '#A0C46C' : '#DDD'}">${user.userStatus eq 1 ? '有效' : '已冻结'}</td>
						<td>${user.userPhoneNumber ne null && user.userPhoneNumber ne '' ? user.userPhoneNumber : '/'}</td>
						<td>${user.userMail ne null && user.userMail ne '' ? user.userMail : '/'}</td>
						<td>
							<c:choose>
								<c:when test="${user.lastLogonTime ne null}">
									<fmt:formatDate  value="${user.lastLogonTime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
								</c:when>
								<c:otherwise> / </c:otherwise>
							</c:choose>
						<td>${user.lastLogonIP ne null && user.lastLogonIP ne '' ? user.lastLogonIP : '/'}</td>
						<td>
							<c:choose>
								<c:when test="${user.roleKey ne 'ROLE_SUPER'}">
									<c:choose>
										<c:when test="${user.userStatus eq 1}">
											<a href="app/system/account.do?action=actionFreezeUser&id=${user.id}" target="ajaxTodo" title="您确定将‘${user.username}’ 的账号冻结吗？<br/>冻结以后该账号将不允许登录系统" class="oplink" callback="tab_reload()">冻结</a>
										</c:when>
										<c:otherwise>
											<a href="app/system/account.do?action=actionActivateUser&id=${user.id}" target="ajaxTodo" title="您确定将‘${user.username}’ 的账号激活吗？" class="oplink" callback="tab_reload()">激活</a>
										</c:otherwise>
									</c:choose>
								</c:when>
								<c:otherwise>
									<label class="opdisabled" title="该账号不能做被冻结">冻结</label>
								</c:otherwise>
							</c:choose>
						</td>
						<td>
							<a href="app/system/account.do?action=actionResetPassword&id=${user.id}" target="ajaxTodo" callback="after_reset()" title="您确定将‘${user.username}’ 的账号重置密码吗？<br/>重置后的密码与登录帐号相同" class="oplink" >重置密码</a>
						</td>
						<td>
							<c:choose>
								<c:when test="${user.roleKey ne 'ROLE_SUPER'}">
									<a href="app/system/account.do?action=dialogAccountPage&id=${user.id}" target="dialog" title="账号编辑" class="oplink" width="584" height="358" rel="sysmgr_account_usrEdit_${user.id}">编辑</a>
								</c:when>
								<c:otherwise>
									<label class="opdisabled" title="该账号不能被编辑">编辑</label>
								</c:otherwise>
							</c:choose>
						</td>
						<td>
							<c:choose>
								<c:when test="${user.roleKey ne 'ROLE_SUPER'}">
									<a href="app/system/account.do?action=actionRemoveUser&id=${user.id}" target="ajaxToDo" title="确定要删除账号`${user.username}`么?" class="oplink" callback="callback_userRemove(${user.id})">删除</a>
								</c:when>
								<c:otherwise>
									<label class="opdisabled" title="该账号不能被删除">删除</label>
								</c:otherwise>
							</c:choose>
						</td>
					</tr>
				</logic:iterate>
			</logic:present>
		</tbody>
	</table>
	
	<!-- Pagination -->
	<div class="panelBar">
		<div class="pages">
			<span>显示</span>
			<select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
				<option value="20" ${pagingBean ne null && pagingBean.pageSize eq 20 ? 'selected="selected"' : ''}>20</option>
				<option value="50" ${pagingBean ne null && pagingBean.pageSize eq 50 ? 'selected="selected"' : ''}>50</option>
				<option value="100" ${pagingBean ne null && pagingBean.pageSize eq 100 ? 'selected="selected"' : ''}>100</option>
				<option value="200" ${pagingBean ne null && pagingBean.pageSize eq 200 ? 'selected="selected"' : ''}>200</option>
			</select>
			<span>条，共${pagingBean ne null ? pagingBean.totalItems : 0}条</span>
		</div>
		
		<div class="pagination" targetType="navTab" totalCount="${pagingBean ne null ? pagingBean.totalItems : 0}" numPerPage="${pagingBean ne null ? pagingBean.pageSize : 20}" pageNumShown="${pagingBean ne null ? pagingBean.pageNumShown : 10}" currentPage="${pagingBean ne null ? pagingBean.currentPage : 1}"></div>

	</div>
		
	</form>
</div>